package com.liu.yuoj.model.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 刘渠好
 * @since 2025-01-13 21:11
 * 题目提交语言枚举类
 */
@Getter
public enum QuestionSubmitLanguageEnum {

    JAVA("java","java"),
    PYTHON("python","python"),
    GO("go","go");

    private String text;

    private String value;

    QuestionSubmitLanguageEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    //根据value查找对应枚举值
    public static QuestionSubmitLanguageEnum getEnumByValue(String value) {
        if (StrUtil.isBlank (value)){
            return null;
        }
        for (QuestionSubmitLanguageEnum lang : values()) {
            if (lang.getValue ().equals(value)) {
                return lang;
            }
        }
        return null;
    }

    //返回枚举值集合
    public  static  List<String> getValues() {
        return Arrays.stream (values ()).map (item->item.value).collect(Collectors.toList());
    }



}
